#ifndef SESSIONFRIENDAREA_H
#define SESSIONFRIENDAREA_H

#include <QWidget>
#include <QScrollArea>
#include <QLabel>

//枚举 三个按钮 不同的中间列表展示。
enum ItemType{
    SESSIONITEM,
    FRIENDITEM,
    APPLYITEM
};

class SessionFriendArea : public QScrollArea
{
    Q_OBJECT
public:
    explicit SessionFriendArea(QWidget *parent = nullptr);
    //添加一个Item
    void addItem(ItemType itemType, const QString& id, const QIcon &avatar, const QString &name, const QString &text);
    //清楚Item
    void clear();

    //
    void clickItem(int index);

private:
    QWidget *container;
    ItemType itemType;
signals:

};

class SessionFriendItem :public QWidget
{
    Q_OBJECT
public:
    SessionFriendItem(QWidget* owner,const QIcon& heads,const QString& name,const QString& text);

    void select();
protected:
    //绘画事件,bug 选中但头像区域没有背景变化的解决方案
    void paintEvent(QPaintEvent*);
    //鼠标点击事件
    void mousePressEvent(QMouseEvent *event);

    //鼠标悬停（进入）事件
    void enterEvent(QEnterEvent* event);

    //鼠标离开事件
    void leaveEvent(QEvent *event);

protected:
    QLabel* messageLabel;
private:
    // QIcon heads;
    // QString

    QWidget *owner;
     bool selected = false;
};

class SessionItem :public SessionFriendItem
{
    Q_OBJECT
public:
    SessionItem(QWidget *onwer,const QString& id,const QIcon& heads,const QString& name,const QString& text);
private:
    QString chatSessionId;
};

class FriendItem :public SessionFriendItem
{
    Q_OBJECT
public:
    //这里的Id为 用户id，
    FriendItem(QWidget *onwer,const QString& id,const QIcon& heads,const QString& name,const QString& description);
private:
    QString userId;
};

class ApplyItem :public SessionFriendItem
{
    Q_OBJECT
public:
    //这里的Id为 用户id
    ApplyItem(QWidget *onwer,const QString& id,const QIcon& heads,const QString& name);
private:
    QString userId;
};
#endif // SESSIONFRIENDAREA_H
